<%@ page import="java.util.ArrayList" %>
<%@ page import="model.StudentClass" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: 86189
  Date: 2023/5/19
  Time: 19:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>班级信息</title>
</head>
<body>
<table border="1"  width="500" class="table table-striped table-bordered table-hover table-condensed">
    <caption><H3>班级信息</H3></caption>
    <tr><th>班级编号</th><th>班级名称</th><th>所属院系</th></tr>
    <%-- 	要在jsp页面中使用<c>标签的foreach遍历，要注意一下两点：
        1.在jsp开头引入c标签
        <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
        2.引入jstl的jar包，可以直接使用lib文件夹也可以使用maven --%>
    <%
        ArrayList<StudentClass> classList=(ArrayList<StudentClass>) request.getAttribute("classList");
        out.print(classList.size());
        out.print(classList.get(0).getClname());
        pageContext.setAttribute("classes", classList);
        %>
    <%
        for(StudentClass studentClass:classList)
        {
    %>
    <tr>
        <td>
          <%=studentClass.getClno()%>
        </td>
        <td>
            <%=studentClass.getClname()%>
        </td>
        <td>
            <%=studentClass.getDno()%>
        </td>
    </tr>
    <%}%>
    <%

        List<String> names = new ArrayList<String>();

        names.add("zhangSan");

        names.add("liSi");

        names.add("wangWu");

        names.add("zhaoLiu");

        pageContext.setAttribute("ns",names);

    %>

    <c:forEach var="item" items="${ns}">

        <c:out value="name: ${item }"/><br/>

    </c:forEach>

    <c:forEach items="${classes}" var="class">
        <tr>
            <td>${class.clno}</td>
            <td>${class.clname}</td>
            <td>${class.dno}</td>
        </tr>
    </c:forEach>

</table>
</body>
</html>
